<template>
  <div>
    <el-dialog title="伪线索" :visible.sync="open" append-to-body>
      <el-form ref="form" :rules="rules" :model="form">
        <el-form-item label="原因" prop="reason">
          <el-select v-model="form.reason" placeholder="请选择用户" clearable>
            <el-option v-for="dict in dict.type.reasons_for_reporting"
                       :key="dict.value"
                       :label="dict.label"
                       :value="dict.value"/>
          </el-select>
        </el-form-item>
        <el-form-item label="原因">
          <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
            v-model="form.remark">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="open=false">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {weixs} from "@/api/crm/clue";

export default {
  name: "false-clue",
  dicts: ["reasons_for_reporting"],
  data() {
    return {
      open: false,
      form: {},
      id: null,
      rules: {
        reason: [{required: true, message: '原因不能为空', trigger: 'blur'}]
      }
    }
  }, methods: {
    submitForm() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.form.id = this.id;
            weixs(this.form).then(data =>{
              this.$modal.msgSuccess("操作成功");
              this.open=true;
              this.$emit("success")
            })
        }
      })
    },
    restform() {
        this.form={
          reason:null,
          remark:null,
        }
    }
  }
}
</script>

<style scoped>

</style>
